import { createWebHashHistory, createRouter } from 'vue-router';

import Home from '@/views/volunteer/home/index.vue';

const routes = [
  // 高报部分
  {
    path: '/',
    redirect: '/home',
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
  },
  {
    path: '/collegeVolunteer',
    name: 'CollegeVolunteer',
    component: () =>
      import(
        /* webpackChunkName: "college-volunteer" */ '@/views/volunteer/collegeVolunteer/index.vue'
      ),
    meta: {
      keepAlive: true,
    },
  },
  {
    path: '/myVolunteerTable',
    name: 'MyVolunteerTable',
    component: () =>
      import(
        /* webpackChunkName: "my-volunteer-table" */ '@/views/volunteer/myVolunteerTable/index.vue'
      ),
  },
  {
    path: '/collectList',
    name: 'CollectList',
    component: () =>
      import(
        /* webpackChunkName: "my-volunteer-table" */ '@/views/volunteer/myVolunteerTable/collectList.vue'
      ),
  },
  {
    path: '/volunTeerDetail',
    name: 'VolunTeerDetail',
    component: () =>
      import(
        /* webpackChunkName: "volunTeer-detail" */ '@/views/volunteer/volunTeerDetail/index.vue'
      ),
  },
  {
    path: '/intelligenceVolunteer',
    name: 'IntelligenceVolunteer',
    component: () =>
      import(
        /* webpackChunkName: "intelligence-volunteer" */ '@/views/volunteer/intelligenceVolunteer/index.vue'
      ),
  },
  {
    path: '/conditionSelect',
    name: 'ConditionSelect',
    component: () =>
      import(
        /* webpackChunkName: "intelligence-volunteer-detail" */ '@/views/volunteer/intelligenceVolunteer/conditionSelect.vue'
      ),
  },
  {
    path: '/createVolunteer',
    name: 'CreateVolunteer',
    component: () =>
      import(
        /* webpackChunkName: "intelligent-create-volunteer" */ '@/views/volunteer/intelligenceVolunteer/createVolunteer.vue'
      ),
  },
  {
    path: '/guide',
    name: 'Guide',
    component: () =>
      import(
        /* webpackChunkName: "guide" */ '@/views/volunteer/guide/index.vue'
      ),
  },

  // 院校部分
  {
    path: '/collegeSearch', // 之前的路由是 '/'
    name: 'CollegeSearch',
    component: () =>
      import(
        /* webpackChunkName: "college-search-home" */ '@/views/collegeSearch/home/index.vue'
      ),
  },
  {
    path: '/searchCollege',
    name: 'SearchCollege',
    component: () =>
      import(
        /* webpackChunkName: "college-search-searchCollege" */ '@/views/collegeSearch/searchCollege/index.vue'
      ),
    meta: {
      keepAlive: true,
    },
  },
  {
    path: '/schoolDetail',
    name: 'SchoolDetail',
    component: () =>
      import(
        /* webpackChunkName: "college-search-schoolDetail" */ '@/views/collegeSearch/schoolDetail/index.vue'
      ),
  },
  {
    path: '/college-favorites', // 之前的路由是 '/favorites'
    name: 'CollegeFavorites',
    component: () =>
      import(
        /* webpackChunkName: "college-search-favorites" */ '@/views/collegeSearch/favorites/index.vue'
      ),
  },
  // 专业部分
  {
    path: '/majorSearch', // 之前的路由是 '/'
    name: 'MajorSearch',
    component: () =>
      import(
        /* webpackChunkName: "major-search-home" */ '@/views/majorSearch/home/index.vue'
      ),
  },
  {
    path: '/searchMajor',
    name: 'SearchMajor',
    component: () =>
      import(
        /* webpackChunkName: "major-search-searchMajor" */ '@/views/majorSearch/searchMajor/index.vue'
      ),
    meta: {
      keepAlive: true,
    },
  },
  {
    path: '/majorDetail',
    name: 'MajorDetail',
    component: () =>
      import(
        /* webpackChunkName: "major-search-majorDetail" */ '@/views/majorSearch/majorDetail/index.vue'
      ),
  },
  {
    path: '/major-favorites', // 之前的路由是 '/favorites'
    name: 'MajorFavorites',
    component: () =>
      import(
        /* webpackChunkName: "major-search-favorites" */ '@/views/majorSearch/favorites/index.vue'
      ),
  },
  // 新高考选科
  {
    path: '/subjectSelect',
    name: 'SubjectSelect',
    component: () =>
      import(
        /* webpackChunkName: "subject-select" */ '@/views/subjectSelect/home/index.vue'
      ),
  },
  // 新高考选科
  {
    path: '/subjectCompare',
    name: 'SubjectCompare',
    component: () =>
      import(
        /* webpackChunkName: "subject-select" */ '@/views/subjectSelect/subjectCompare/index.vue'
      ),
  },
  {
    path: '/intelligenceSubject',
    name: 'IntelligenceSubject',
    component: () =>
      import(
        /* webpackChunkName: "intelligence-subject" */ '@/views/subjectSelect/intelligenceSubject/index.vue'
      ),
  },
  {
    path: '/createMap',
    name: 'CreateMap',
    component: () =>
      import(
        /* webpackChunkName: "create-map" */ '@/views/subjectSelect/intelligenceSubject/createMap.vue'
      ),
  },
  {
    path: '/graph',
    name: 'Graph',
    component: () =>
      import(
        /* webpackChunkName: "graph" */ '@/views/subjectSelect/graph/index.vue'
      ),
    meta: {
      keepAlive: true, // 标记需要缓存
    },
  },
  {
    path: '/subjectReport',
    name: 'SubjectReport',
    component: () =>
      import(
        /* webpackChunkName: "subject-report" */ '@/views/subjectSelect/subjectReport/index.vue'
      ),
  },
  {
    path: '/compareReport',
    name: 'CompareReport',
    component: () =>
      import(
        /* webpackChunkName: "compare-report" */ '@/views/subjectSelect/compareReport/index.vue'
      ),
  },
  // 职业部分
  {
    path: '/positionDetail',
    name: 'PositionDetail',
    component: () =>
      import(
        /* webpackChunkName: "position-detail" */ '@/views/position/positionDetail/index.vue'
      ),
  },
  // 公共页面
  {
    path: '/iframeSitePage',
    name: 'IframeSitePage',
    component: () =>
      import(
        /* webpackChunkName: "iframe-site-page" */ '@/views/iframeSitePage/index.vue'
      ),
  },
  // 产企图谱start
  {
    path: '/industryHome',
    name: 'IndustryHome',
    component: () =>
      import(
        /* webpackChunkName: "IndustryList" */ '@/views/industryMap/industryHome/index.vue'
      ),
  },
  {
    path: '/industryDetail',
    name: 'IndustryDetail',
    component: () =>
      import(
        /* webpackChunkName: "IndustryDetail" */ '@/views/industryMap/industryDetail/index.vue'
      ),
  },
  // 产企图谱end
];

// 存储上一个路由信息
let previousRoute = null;

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

router.beforeEach((to, from) => {
  previousRoute = from;
  return true;
});

export { router, previousRoute };
